//
//  SGActivityModel.swift
//  songguo
//
//  Created by 潘传洲 on 16/6/11.
//  Copyright © 2016年 pcz. All rights reserved.
//

import UIKit

class SGActivityModel: SGSpecificModel {
    
    var name: String?
    var st: Double?
    var et: Double?
    var address: String?
    var ct: Double?
    var geo : SGGeoModel?

    
    
    class func initWithDict(dict : [String : AnyObject]) -> SGActivityModel {
    
        let activity = SGActivityModel()

        activity.name = dict["name"] as? String
        activity.st = dict["st"] as? Double
        activity.et = dict["et"] as? Double
        activity.ID = dict["id"] as? String
        activity.address = dict["address"] as? String
        
        let resources = SGResourceModel.resourceModels(dict["resource"] as! [[String : AnyObject]])
        var specificViewModels = [SGSpecificViewModel]()
        for resource in resources {
            specificViewModels.append(SGSpecificViewModel.initWithResourceModel(resource))
        }
        activity.specificViewModels = specificViewModels
        
         /// 封面图片
        let cover = dict["cover"] as! [String : AnyObject]
        activity.coverUrl = cover["url"] as? String
        
        let topImage = dict["topImage"] as! [String : AnyObject]
        activity.topImageUrl = topImage["url"] as? String
        
        // 地理位置
        activity.geo = SGGeoModel.initWithDict(dict["geo"] as! [String : AnyObject])

        return activity
    }

}
